
<template>
	<view>
	<view :style="{'height': titleHeight + statusHeight + 'px'}"></view>
	<view class="static" :style="{
		'background-color': bgcolor? bgcolor : '', 
		'color': color}">
		
		<!-- 状态栏 -->
		<view :style="{'height': statusHeight + 'px'}"></view>
		
		<!-- 标题栏 -->
		<view class="title_area" :style="{'height': titleHeight + 'px'}">
			
			<!-- 最左侧可更换图标区 -->
			<view class="btn_icon" v-if="btnSrc" @click="btnClick">
				<image :src="btnSrc"></image>
			</view>
			
			<!-- 标题前图标 -->
			<view class="title_icon" v-if="titleIconSrc" @click="btnClick">
				<image :src="titleIconSrc"></image>
			</view>
			
			<!-- 标题字体 -->
			<view class="title_text" v-if="title" @click="btnClick">
				{{title}}
			</view>
			
		</view>
		
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//沉浸状态栏两高度
				titleHeight: uni.getSystemInfoSync().system.includes('Android') ? 48 : 44,
				statusHeight: uni.getSystemInfoSync().statusBarHeight,
			};
		},
		props: {
			title: {
				type: String,
				default: '',
				required: false,
			},
			btnSrc: {
				type: String,
				default: '',
				required: false,
			},
			titleIconSrc: {
				type: String,
				default: '',
				required: false,
			},
			bgcolor: {
				type: String,
				default: '',
				required: false,
			},
			color: {
				type: String,
				default: '#000000',
				required: false,
			},
		},
		methods: {
			btnClick() {
				console.log('组件按钮点击')
				this.$emit('btnClick')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.static {
		width: 100%;
		display: flex;
		flex-direction: column;
		
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		overflow: hidden;
		background-color: #FFFFFF;
		z-index: 9;

		.title_area {
			display: flex;
			align-items: center;
			width: 100%;
			padding-left: 20rpx;
			box-sizing: border-box;
			
			.btn_icon {
				
				height: 42rpx;
				width: 42rpx;
				padding-right: 20rpx;
				
				image {
					width: 100%;
					height: 100%;
				}
			}
			
			.title_icon {
				height: 38rpx;
				width: 38rpx;
				
				image {
					width: 100%;
					height: 100%;
				}
			}
			
			.title_text {
				font-size: 30rpx;
				margin-left: 10rpx;
			}
		}
	}
</style>
